Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): various makefile improvements #3410

Merged
merged 3 commits into from
Jan 17, 2025

Conversation

johncowen
Copy link
Contributor

@johncowen johncowen commented Jan 16, 2025

I stumbled across quite a few things whilst fixing up our clean script so:

  1. It can be run from any sub-package (like make install)
  2. It didn't echo the warning message twice in certain environments

I have a longer term goal of making our "wiring root" Makefiles easier to maintain (there might end up being lots of them) and possibly creating them from a template. This goal means that the less path differences etc (../ over here, ./ over there) the better. This has influenced some decisions here.

In order to run make clean from anywhere and it automatically do this from root, we need to know where root is, from wherever we are. This led me to using npm prefix for NPM_WORKSPACE_ROOT. This led me to realize a NPM_WORKFLOW_CONFIG_PATH that I'd not noticed in a previous PR, which led me to our release script. Getting here made me realize our release script wasn't working since we moved our mk files over to @kumahq/config.

Hopefully the above explains why this is "various" things rather than just the one.

make release/prune fixes

Since we moved mk to @kumahq/config, and we also rm @kumahq/config during SBOM generation, this means we can no longer run any Makefiles after SBOM generation, doh 🤦

I figured that we only want to delete the dependency configuration for the SBOM generation, not the entire @kumahq/config module. Additionally our SBOM generation ignores devDependencies, and @kumahq/config is a devDependency but its dependencies are not (ideally our SBOM generator would ignore devDependencies entirely but hey ho).

This PR runs a tiny script before SBOM generation that moves @kumahq/configs package config for dependencies to devDependencies and also deletes its peerDependencies. We then run npm install --package-lock-only as before. This I believe has the exact same effect as rming the entire @kumahq/config` module, but without also deleting our Makefile tooling/scripts.

make clean

Can now be run from any repository in the workspace or from the root. I also added a confirmation (if not in CI) so that you have some kind of visibility into what its deleting and a chance to say no.

make variables

I added some useful variables into help.mk, which are necessary for all scripts. I added them to help.mk because I would like to make it easy to add the help make target and make it hard not to. Adding them to make means you must include help.mk

copypasta ability

I made it so the top ~11 lines of every Makefile are exactly the same, this makes it easy to copy/paste them to make multiple ones and keep them in sync i.e. poor mans templating (we may add templating at some point but I doubt it)

wait for a system/application to test

Lastly I added a wait for our test site to come up, cypress wasn't waiting long enough and even before this it would try 3 times before (sometimes) succeeding. make now tales a split second longer due to the new variables, so I added a quick check for our application being served on localhost:5681 before running Cypress.

I may add some inlines.

Copy link

netlify bot commented Jan 16, 2025

Deploy Preview for kuma-gui ready!

Name Link
🔨 Latest commit 1d81b99
🔍 Latest deploy log https://app.netlify.com/sites/kuma-gui/deploys/678a501ca1cfc7000839f8f0
😎 Deploy Preview https://deploy-preview-3410--kuma-gui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@johncowen johncowen force-pushed the chore/mk-imp branch 4 times, most recently from 1a124e6 to 53fc3d6 Compare January 16, 2025 16:40
@johncowen johncowen marked this pull request as ready for review January 16, 2025 17:00
@johncowen johncowen requested a review from a team as a code owner January 16, 2025 17:00
@johncowen johncowen requested review from schogges and removed request for a team January 16, 2025 17:00
Copy link
Contributor

@schogges schogges left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@johncowen
Copy link
Contributor Author

@schogges I made an addition here in 1d81b99 to make the sbom exclusion reusable for when/if we need to exclude any more workspace modules from our SBOM. Figured I'd ping you for some 👀 just incase.

Copy link
Contributor

@schogges schogges left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@johncowen johncowen merged commit 601d095 into kumahq:master Jan 17, 2025
17 checks passed
johncowen added a commit that referenced this pull request Jan 20, 2025
Follow up of #3410

---

Turns out `npm query` requires your `node_modules` to be present, I've
no idea why 🤷 , and we have a target that we sometimes run that needs to
run before a `make install` (`make release/prune`) 🤦 .

I saw that you can add a `npm --package-lock-file-only query` to get it
to use the lock file instead of needing access to `node_modules`. This
works when running from workspace root without `node_modules`, but when
you run a Makefile from a sub project without `node_modules` adding this
arg/flag still fails 🤷

I've fallen back to just jq-ing the package-lock.json myself at least
for the moment so we can unblock the release workflow. If I find a
slightly nicer way to do this in the future I'll replace, but I really
want to stick to the runtime resolution of things rather than hardcoding
paths in several files.

How to test:

- Run `make clean` to remove all your `node_modules` folders
- cd into or use `make -C` to run `make release/prune` from within
`packages/kuma-gui`
- Verify that `packages/config` has changes to package.json and
package-lock.json also has changes.

I 'think' this will finally unblock the release workflow 🤞 

---

edit: I just checked a this new approach actually works better elsewhere
also 🎉

Signed-off-by: John Cowen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants